import {
  PlusIcon,
} from 'tdesign-icons-react'
import ReactIcon from '@/assets/icons/common/react.svg?react'
import TDesignIcon from '@/assets/icons/common/tdesign.svg?react'

const Icons = (props: any) => {

  const {
    icon = '',
    size = '',
    color = '',
    className = '',
    style = {},
    onClick = () => { },
    isTdIcon = false
  } = props

  const realIconPath = icon.startsWith('http') ? icon : `/src/assets/icons/${icon.replace('-', '/')}.svg`

  const renderTdIcon = () => {
    switch (icon) {
      case 'PlusIcon':
        return <PlusIcon size={size} />
      default:
        return <PlusIcon size={size}/>
    }
  }

  const renderCustomIcon = () => {
    switch (icon) {
      case 'common-react':
        return <ReactIcon className={className} />
      case 'common-tdesign':
        return <TDesignIcon />
    }
  }

  // return isTdIcon ? renderTdIcon() : <img src={realIconPath} style={{ width: size, height: size, color, ...style }} className={className} onClick={onClick} />
  return isTdIcon ? renderTdIcon() : renderCustomIcon()
}

export default Icons
